function factorial (num) {
  if(num <= 1){
    return 1;
  }else{
    return num * factorial(num -1);
  }
}

//factorial与内部factorial函数紧密耦合
let testFunc = factorial;

factorial = function () {
  return 0;
}

console.log('耦合：', testFunc(4));

//优化解耦
function factorial1 (num) {
  if(num <= 1){
    return 1;
  }else{
    return num * arguments.callee(num -1);  //这里使用函数内部arguments的callee属性，arguments保存函数参数，callee属性是一个指针，指向拥有arguments对象的函数
  }
}

//factorial与内部factorial函数紧密耦合
let testFunc1 = factorial1;

factorial1 = function () {
  return 0;
}

console.log('解耦：', testFunc1(4));